package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.AfoneshopAd;
import com.example.demo.mapper.AfoneshopAdMapper;
import com.example.demo.service.IAfoneshopAdService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 广告 服务实现类
 * </p>
 *
 * @author Mr.Xiayh
 * @since 2024-06-16
 */
@Service
public class AfoneshopAdServiceImpl extends ServiceImpl<AfoneshopAdMapper, AfoneshopAd> implements IAfoneshopAdService {
    @Resource
    private AfoneshopAdMapper afoneshopAdMapper;

    @Override
    public AfoneshopAd queryObject(Integer id) {
        return afoneshopAdMapper.selectById(id);
    }

    @Override
    public List<AfoneshopAd> queryList(Map<String, Object> map) {
        return afoneshopAdMapper.selectByMap(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return afoneshopAdMapper.queryTotal(map);
    }

    @Override
    public boolean save(AfoneshopAd brand) {
        afoneshopAdMapper.insert(brand);
        return false;
    }


    public void update(AfoneshopAd brand) {
        QueryWrapper<AfoneshopAd> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", brand.getId());
        afoneshopAdMapper.update(queryWrapper);
    }


    public void delete(Integer id) {
        QueryWrapper<AfoneshopAd> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", id);
        afoneshopAdMapper.delete(queryWrapper);
    }


    public void deleteBatch(Integer[] ids) {
        Collection<Integer> idsList = List.of(ids);
        afoneshopAdMapper.deleteBatchIds(idsList);
    }
}
